package com.news.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.news.entity.News;
import com.news.entity.User;
import com.news.service.NewsService;
import com.news.service.UserService;


@WebServlet("/adminnewseditpage")
public class AdminNewsEditPageServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//1.获取到参数id
		String id = request.getParameter("id");			
		//2.调用service，根据id查询用户数据
		UserService userService = new UserService();
		User user = userService.getById(Integer.parseInt(id));
		HttpSession session=request.getSession();
		session.setAttribute("id", Integer.parseInt(id));		
		//3.将用户数据通过请求转发跳转到edit.jsp页面
		request.setAttribute("user", user);
		request.getRequestDispatcher("/jsp/admineditnews.jsp").forward(request, response);
	}

}
